package feeelinganalyzer.crawler;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintStream;
import java.util.List;

public class Writer {

	private PrintStream stream;

	public Writer(int idDados) {
		try {
			stream = new PrintStream(
					new File(CrawlerConstants.TWEETS_DIR
							+ CrawlerConstants.FILE_SEPARATOR + "coleta" + idDados
							+ ".txt"));
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}
	}
	
	public void writeToFile(List<String> lines){
		for (String string : lines) {
			System.out.println("===Saving Tweet: " + string);
			stream.append(string + CrawlerConstants.LINE_SEPARATOR);
		}
	}
	
	public void closeFile(){
		stream.flush();
		stream.close();
	}
}
